fix(integrations): exit cleanly on unbalanced quote in --integration-options (#3457)#3466
Open
Noor-ul-ain001 wants to merge 1 commit into
Open
Conversation
…options (github#3457) `_parse_integration_options` called `shlex.split(raw_options)` unguarded, so an unbalanced quote in the flag value (e.g. `--integration-options='--commands-dir "foo'`) made shlex raise `ValueError: No closing quotation` and a raw traceback escaped — unlike every other bad-input path in this function (unknown option, missing value, unexpected value), which print a message and exit 1. Reachable from `specify init --integration-options=...` and every `specify integration install/switch/upgrade/migrate --integration-options=...`. Wrap the split in a try/except ValueError that prints a one-line error and raises `typer.Exit(1)`, matching the existing loud-fail UX. Add a test asserting the unbalanced-quote input raises `typer.Exit` with exit code 1. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #3457.
_parse_integration_optionsinsrc/specify_cli/integrations/_helpers.pycalledshlex.split(raw_options)unguarded. An unbalanced quote in the flag value made shlex raiseValueError: No closing quotation, so a raw traceback escaped instead of the cleantyper.Exit(1)error every other bad-input path in this function produces (unknown option, missing value, unexpected value all print a message and exit 1).Reachable from
specify init --integration-options=...and everyspecify integration install/switch/upgrade/migrate --integration-options=....Before:
After:
Changes
shlex.split(raw_options)intry/except ValueError, printing a one-line error and raisingtyper.Exit(1)— matching the loud-fail UX of the sibling bad-input branches in the same function.Testing
test_unbalanced_quote_exits_cleanlyunderTestParseIntegrationOptionsEqualsForm: asserts the unbalanced-quote input raisestyper.Exitwith exit code 1.ValueErrorpropagates).CliRunneron the fullintegration install ... --integration-optionspath: exit code 1, clean message, no traceback.pytest tests/integrations/test_integration_subcommand.py→ 108 passed, 7 skipped.🤖 Generated with Claude Code